#include <cstdio>
#include <cstring>
#define F(x) ((x)/3+((x)%3==1?0:tb))
#define G(x) ((x)<tb?(x)*3+1:((x)-tb)*3+2) 
const int maxn = 160010;
int wa[maxn], wb[maxn], wv[maxn], ws[maxn], rank[maxn], height[maxn], sa[maxn], s[maxn];

int c0(int *r,int a,int b) 
{return r[a]==r[b]&&r[a+1]==r[b+1]&&r[a+2]==r[b+2];} 
int c12(int k,int *r,int a,int b) 
{if(k==2) return r[a]<r[b]||r[a]==r[b]&&c12(1,r,a+1,b+1); 
else return r[a]<r[b]||r[a]==r[b]&&wv[a+1]<wv[b+1];} 

void sort(int *r,int *a,int *b,int n,int m) 
{ 
    int i; 
    for(i=0;i<n;i++) wv[i]=r[a[i]]; 
    for(i=0;i<m;i++) ws[i]=0; 
    for(i=0;i<n;i++) ws[wv[i]]++; 
    for(i=1;i<m;i++) ws[i]+=ws[i-1]; 
    for(i=n-1;i>=0;i--) b[--ws[wv[i]]]=a[i]; 
    return; 
}

void dc3(int *r,int *sa,int n,int m)
{ 
    int i,j,*rn=r+n,*san=sa+n,ta=0,tb=(n+1)/3,tbc=0,p; 
    r[n]=r[n+1]=0; 
    for(i=0;i<n;i++) if(i%3!=0) wa[tbc++]=i; 
    sort(r+2,wa,wb,tbc,m); 
    sort(r+1,wb,wa,tbc,m); 
    sort(r,wa,wb,tbc,m); 
    for(p=1,rn[F(wb[0])]=0,i=1;i<tbc;i++) 
    rn[F(wb[i])]=c0(r,wb[i-1],wb[i])?p-1:p++; 
    if(p<tbc) dc3(rn,san,tbc,p); 
    else for(i=0;i<tbc;i++) san[rn[i]]=i;
    for(i=0;i<tbc;i++) if(san[i]<tb) wb[ta++]=san[i]*3; 
    if(n%3==1) wb[ta++]=n-1; 
    sort(r,wb,wa,ta,m); 
    for(i=0;i<tbc;i++) wv[wb[i]=G(san[i])]=i; 
    for(i=0,j=0,p=0;i<ta && j<tbc;p++) 
    sa[p]=c12(wb[j]%3,r,wa[i],wb[j])?wa[i++]:wb[j++]; 
    for(;i<ta;p++) sa[p]=wa[i++]; 
    for(;j<tbc;p++) sa[p]=wb[j++]; 
    return; 
}

void calheight(int *r, int n)
{
    int i, j, k = 0 ;
    for(i=1; i<=n; i++) rank[sa[i]] = i;
    for(i=0; i<n; height[rank[i++]]=k)
        for(k?k--:0, j=sa[rank[i]-1]; r[i+k]==r[j+k]; k++) ;
    return ;
}

int m, n;
char str[ maxn ];

void init( )
{
    int i;
    scanf("%s", str);
    n = strlen( str );
    for ( i = 0; i < n; i++ )
        s[ i ] = str[ i ] - 'a' + 1;
    s[ n ] = 0;
    dc3( s, sa, n + 1, 30 );
    calheight( s, n );
}
/*
void init( )
{
    int i;
    scanf("%s", str);
    n = strlen( str );
    for ( i = 0; i < n; i++ )
        s[ i ] = str[ i ] - 'a' + 1;
    s[ n ] = 0;
    da( s, n + 1, 27 );
    calheight( s, n );
}
*/
void work( )
{
    int i, j, l = 1, r = n, mid, mm, c, ans = -1, aa, ab;
    while ( l <= r )
    {
        mid = ( l + r ) / 2;
        mm = 0;
        c = 0;
        for ( i = 2; i <= n; i++ )
            if ( height[ i ] < mid )
                c = 0;
            else
            {
                c++;
                if ( mm < c ) mm = c;
            }
        if ( mm + 1 < m )
            r = mid - 1;
        else
        {
            ans = mid;
            l = mid + 1;
        }
    }
    if ( ans == -1 )
    {
        puts("none");
        return ;
    }
    c = 0;
    aa = ab = 0;
    for ( i = 2; i <= n; i++ )
        if ( height[ i ] < ans )
            aa = c = 0;
        else
        {
            c++;
            if ( aa < sa[ i - 1 ] ) aa = sa[ i - 1 ];
            if ( aa < sa[ i ] ) aa = sa[ i ];
            if ( c + 1 >= m )
                if ( ab < aa )
                    ab = aa; 
        }
    printf("%d %d\n", ans, ab);
}

int main( )
{
    while ( scanf("%d", &m ) && m )
    {
        init( );
        work( );
    }
    return 0;
}